<!DOCTYPE html>
<html lang="en">
    <head>
        <title>登录界面</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link href="css/style.css" rel="stylesheet">
    </head>
    <body>
        <div>
            <div>
                账户：<input type="text" id="aname">
            </div>
            <div>
                密码：<input type="password" id="mima">
            </div>
            <div>
                <button onclick="dengs()">登录</button>
            </div>
        </div>

        <script>
            function dengs(){
                let aname = document.querySelector("#aname")
                let mima = document.querySelector("#mima")

                fetch("/login/ks",{
                    method:"POST",
                    body:JSON.stringify({
                        aname:aname.value,
                        mima:mima.value
                    }),
                    headers:{
                        "Content-Type":"application/json"
                    }
                }).then(res=>res.json()).then(res=>{
                    console.log(res);
                    if(res.ok === 1){
                        // 跳转
                        location.href = '/';
                    }else{
                        alert("账户密码错误；");
                    }
                })
                    
            }
            
        </script>
    </body>
</html>